var str1 = 'hello \nworld'
var str2 = `hello
world 
`
var name="蔡老师"
var favor = "唱歌"
var str3 = `大家好我是:${name}，年龄${10+12}，我的爱好是${favor+"、跳舞"}`

var arr = ['A', 'B', 'C', 'D', 'E'];
//字符串是不能被改变的数据
//字符串转数组
var str3 = "A-BC-DE"
var arr3 = str3.split('-')
//这是给str3这个变量从新赋值而不是去改变"A-BC-DE"字符串
str3 = 'haha'
//如果不填写参数则字符串不会被分离成数组，而是把整个字符串放进一个数组
var arr4 = str3.split()
//如果参数是空字符串，那么字符串的所有字符将会被分离
var arr5 = str3.split('')

var n = 123
var nStr = n.toString()
var nArr = nStr.split('')
var gw = nArr[2]
var sw = nArr[1]
var bw = nArr[0]

var code = 1024
var str6 = 'i love you'
// 'abd' 3 0,1,2
var codedStr = ''
//加密过程
for(var i=0;i<= str6.length-1;i++){
    //获取迭代的字符
    var char = str6[i]
    var charCode = char.charCodeAt()//数字，char字符对应的unicode编码
    charCode += code // 对编码进行加密运算
    var codedChar = String.fromCharCode(charCode) // 把加密运算的结果转换成对应的字符
    codedStr += codedChar //codedStr去拼接用加密过后的字符
}
//解密过程
var decodedStr = ''
for(var i=0;i<codedStr.length;i++){
    var char = codedStr[i]
    var charCode = char.charCodeAt()
    charCode -= code
    var decodedChar = String.fromCharCode(charCode) // 把加密运算的结果转换成对应的字符
    decodedStr += decodedChar
}

var char1 = 'e'
var char1Code = char1.charCodeAt() //获取char1的编码
var upperCode = char1Code-32
var charUpper = String.fromCharCode(upperCode)

var str7 = 'i am hungry'

var res7 = str7.slice(0,4)
var res71 = str7.slice(1,-1)

var str8 = '  Hello world!  '
str8.trim()
var res8 = ''
for(var i=0;i<str8.length;i++){
    var char = str8[i]
    if(char !== ' '){
        res8+=char
    }
} 
var c = 'a'
var t = c
// t+='b'
t = t + c


var s = "hello world"
// var ns = s.replace('l','x')//会替换找到的第一个，然后生成一个新的字符串并返回
// var ns1 = s.replace(/l/g,'x')//会替换所有
while(s.includes('l')){
    s = s.replace('l','x')
}




